<?php
/**
 * Archive pages
 * Author : vthanh_88
 * @package WordPress
*/
get_header();
#
# Get Archive
#
$post_type="post";
$archive_title = 'Archives ';
if ( is_day() ) :
	$archive_title.= get_the_date();
	elseif ( is_month() ) :
			$archive_title.= get_the_date('F Y') ;
	elseif ( is_year() ) :
			$archive_title.= get_the_date('Y');
	else :
			$archive_title = "Portfolio  ".$_GET["portfolio-type"] ; 
			$post_type="portfolio";
	endif; 

#
#Get Paged
#
if ( get_query_var('paged') ) {
	$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) { 
	$paged = get_query_var('page');
} else {
	$paged = 1;
}
if($post_type =="post")
{
$posts_per_page = get_theme_option('blog','blog_post_per_page');
update_option("posts_per_page",$posts_per_page);
$sort = get_theme_option('blog','blog_sort');
$args = array(
	'post_type' => 'post',
	'posts_per_page' => $posts_per_page,
	'paged' => $paged,
	'order' => $sort, 
);
}
else
{
$posts_per_page = get_theme_option('blog','blog_post_per_page');

$args = array(
	'post_type' => 'portfolio',
	'posts_per_page' => $posts_per_page,
	'paged' => $paged 
);
$archive_title = 'Archive for ';
}
if(is_page())
{
    
	query_posts($args);
}else{
	global $wp_query;
	$query_args = array_merge( $wp_query->query, $args );
	global $posts;
	$posts=query_posts($query_args);
	}
	
?>
          
    <div class="wrapper">
        <?php get_sidebar(); ?>		 
        <div class="right-panel-outer">
			<div class="right-panel">
			   <div class="right-inner">
                    <h2 class="head"><?php echo 'Page of '.get_the_author();?></h2>
        	   </div>		
			   		<?php
					if($post_type == 'post'):		
    					$author_style = get_theme_option('blog','archid_style');
    					if($author_style == 'style_1'):
                			include_once('loop/loop-blog-1.php');
    					elseif($author_style == 'style_2'):
         					include_once('loop/loop-blog-2.php');
    					endif;
					else:
    					$portfolio_style = get_theme_option('portfolio','archid_style');
    					if($portfolio_style == 'style_1'):
                			include_once('loop/loop-portfolio-1.php');
    					elseif($portfolio_style == 'style_2'):
         					include_once('loop/loop-portfolio-2.php');
    					endif;					 
					endif;
					?>
    	    </div>
			<div class="content-shadow">&nbsp;</div>
        </div>
        <div class="clearfix"></div>
    </div>
<?php

get_footer();  
?>